<?php

namespace Controller\Ajax;

class Message extends Base {

    public function addMessage() {
        $name = $this->postParam('name');
        $phoneNum = $this->postParam('phoneNum');
        $content = $this->postParam('content');
        if(strlen($content) > 200) {
            $content = \Lib\Util\Comm::utf8_truncate($content, 200);
        }
        try{
            \Business\Message::instance()->addMessage($name, $phoneNum, $content);
            $this->response(true);
        } catch (\Lib\Exception\Business $e) {
            $this->responseError($e->getMessage());
        }
    }
}
